package com.lds.config.center.server.business.namespace.converter;

import com.lds.config.center.common.model.namespace.request.NamespaceBaseUpdateRequest;
import com.lds.config.center.server.business.namespace.entity.Namespace;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


@Component
public class NamespaceBaseUpdateRequestToEntityConverter implements Converter<NamespaceBaseUpdateRequest, Namespace> {

    @Override
    public Namespace convert(NamespaceBaseUpdateRequest source) {
        return Namespace.builder()
                .id(source.getId())
                .modifier(source.getModifier())
                .updateTime(LocalDateTime.now())
                .name(source.getName())
                .format(source.getFormat())
                .appId(source.getAppId())
                .desc(source.getDesc())
                .build();
    }

}


